package adsf.adminisadsf.gugedianzishichang.fragment;

import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;

import adsf.adminisadsf.gugedianzishichang.R;
import adsf.adminisadsf.gugedianzishichang.adapter.MyBaseAdapter;
import adsf.adminisadsf.gugedianzishichang.holder.BaseHolder;
import adsf.adminisadsf.gugedianzishichang.holder.HomeHoder;
import adsf.adminisadsf.gugedianzishichang.utils.LoadingPage;
import adsf.adminisadsf.gugedianzishichang.utils.UIUtils;

/**
 * Created by administrator on 17/5/9.
 */

public class HomeFragment extends BaseFragment
{

 private ArrayList<String> data;

    @Override
    public View onCreateSuccessView() {


        ListView listView = new ListView(UIUtils.getContext());
        listView.setAdapter(new HomeAdapter(data));
        return listView;
    }

    @Override
    public LoadingPage.ResultState onLoad() {


         data = new ArrayList<String>();
         for (int i = 0; i < 20; i++) {
         data.add("测试数据:" + i);
         }

        return LoadingPage.ResultState.STATE_SUCCESS;
    }


    //适配器
    class HomeAdapter extends MyBaseAdapter {
        public HomeAdapter(ArrayList data) {
            super(data);
        }

        @Override
        public BaseHolder getHodeler() {
            return new HomeHoder();
        }

        @Override
        public ArrayList onLoadMore() {


             ArrayList<String> moreData = new ArrayList<String>();
             for(int i=0;i<10;i++) {
             moreData.add("测试更多数据:" + i);
             }

             SystemClock.sleep(2000);


            return null;
        }


    }

    public class ViewHolder
    {
        public TextView tvContent;
    }



}






